tyNamespace.OffLineLayer = cc.Layer.extend({
    self: null,

    ctor: function () {
        this._super();

        this.init();

        return true;
    },

    init: function () {
        this.self = this;

        //背景
        var background = new cc.Sprite(gpNamespace.ty.Ty_jumpBackgroundNo);
        background.attr({
            x: cc.winSize.width / 2,
            y: cc.winSize.height / 2
        });
        this.addChild(background);

        //info
        var info = new cc.Sprite(gpNamespace.ty.Ty_jumpOffLine);
        info.attr({
            x: 160,
            y: 170,
            anchorX: 0,
            anchorY: 0
        });
        background.addChild(info);

        //取消
        var cancelItem = new cc.MenuItemImage(gpNamespace.ty.Ty_jumpCancel, gpNamespace.ty.Ty_jumpCancel, this.cancelCallbackFunction, this);
        cancelItem.attr({
            x: 141 / 2,
            y: 68 / 2
        });
        var cancelMenu = new cc.Menu(cancelItem);
        cancelMenu.attr({
            x: 100,
            y: 35
        });
        background.addChild(cancelMenu);

        //确定
        var confirmItem = new cc.MenuItemImage(gpNamespace.ty.Ty_jumpOK, gpNamespace.ty.Ty_jumpOK, this.confirmCallbackFunction, this);
        confirmItem.attr({
            x: 141 / 2,
            y: 68 / 2
        });
        var confirmMenu = new cc.Menu(confirmItem);
        confirmMenu.attr({
            x: 330,
            y: 35
        });
        background.addChild(confirmMenu);
    },

    cancelCallbackFunction: function (sender) {
        cc.log("取消");

        tyNamespace.setMenuEnable(sender);

        this.getParent().removeFromParent(true);

        cc.director.end();
    },

    confirmCallbackFunction: function (sender) {
        cc.log("确定");

        tyNamespace.setMenuEnable(sender);

        var self = this.self;

        var waitingLayer = new gpNamespace.TyWaittingLayer();
        waitingLayer.setName(gpNamespace.Juhua);
        self.addChild(waitingLayer, 5);

        self.scheduleOnce(function () {
            cc.log("断线登陆");

            gpNamespace.Reconnect();
        }, 1);
    }
});

gpNamespace.ReconectLayer = cc.Layer.extend({
    ctor: function () {
        this._super();

        this.init();

        return true;
    },

    init: function () {
        //背景
        var background = new cc.Sprite(gpNamespace.ty.Ty_jumpBackgroundNo);
        background.attr({
            x: cc.winSize.width / 2,
            y: cc.winSize.height / 2
        });
        this.addChild(background);

        //info
        var info = new cc.Sprite(gpNamespace.ty.Ty_jumpReconect);
        info.attr({
            x: 50,
            y: 140,
            anchorX: 0,
            anchorY: 0
        });
        background.addChild(info);

        //取消
        var cancelItem = new cc.MenuItemImage(gpNamespace.ty.Ty_jumpCancel, gpNamespace.ty.Ty_jumpCancel, this.cancelCallbackFunction, this);
        cancelItem.attr({
            x: 141 / 2,
            y: 68 / 2
        });
        var cancelMenu = new cc.Menu(cancelItem);
        cancelMenu.attr({
            x: 100,
            y: 35
        });
        background.addChild(cancelMenu);
        this.cancelMenu = cancelMenu;

        //确定
        var confirmItem = new cc.MenuItemImage(gpNamespace.ty.Ty_jumpOK, gpNamespace.ty.Ty_jumpOK, this.confirmCallbackFunction, this);
        confirmItem.attr({
            x: 141 / 2,
            y: 68 / 2
        });
        var confirmMenu = new cc.Menu(confirmItem);
        confirmMenu.attr({
            x: 330,
            y: 35
        });
        background.addChild(confirmMenu);
        this.confirmMenu = confirmMenu;
    },

    cancelCallbackFunction: function (sender) {
        cc.log("取消");

        gpNamespace.playEffect(gpNamespace.soundRes.ButtonBack, false);

        tyNamespace.setMenuEnable(sender);

        this.getParent().removeFromParent(true);
    },

    confirmCallbackFunction: function (sender) {
        cc.log("确定");

        gpNamespace.playEffect(gpNamespace.soundRes.ButtonEffect, false);

        tyNamespace.setMenuEnable(sender);

        this.getParent().removeFromParent(true);

        //cc.game.restart();
    }
});